﻿using System;
using System.Collections.Generic;

namespace Db7
{
    public class DimensionStyle : VirtualElement
    {
        public DimensionStyle()
        {
            Left = Util.NaN;
            Right = Util.NaN;
            Height = Util.NaN;
        }

        #region Left
        public DblBinder Left_DB;

        public double? Left;

        public double? Left_D
        {
            get { return DblBinder.Get(Left_DB); }
            set { Left_DB = DblBinder.Set(Left_DB, value);}
        }
        #endregion

        #region Right
        public DblBinder Right_DB;

        public double? Right;

        public double? Right_D
        {
            get { return DblBinder.Get(Right_DB); }
            set { Right_DB = DblBinder.Set(Right_DB, value); }
        }
        #endregion

        #region Height
        public DblBinder Height_DB;

        public double? Height;

        public double? Height_D
        {
            get { return DblBinder.Get(Height_DB); }
            set { Height_DB = DblBinder.Set(Height_DB, value); }
        }
        #endregion

        #region Width
        public DblBinder Width_DB;

        public double? Width;

        public double? Width_D
        {
            get { return DblBinder.Get(Width_DB); }
            set { Width_DB = DblBinder.Set(Width_DB, value); }
        }
        #endregion
        #region methods
        //private void AppendStyle(double? val, string name, StringBuilder sb)
        //{
        //    if(val!=null){
        //        sb.AppendLine(name + ":" + val + "px;");
        //    }
        //}
        public void AddToStyles(Dictionary<string, string> styles)
        {
            if (Left != Util.NaN || Left_D != Util.NaN)
            {
                styles["left"] = (Left !=Util.NaN ? Left : Left_D) + "px";
            }
            if (Right != Util.NaN || Right_D != Util.NaN)
            {
                styles["Right"] = (Right != Util.NaN ? Right : Right_D) + "px";
            }
            if (Height != Util.NaN || Height_D != Util.NaN)
            {
                styles["Height"] = (Height != Util.NaN ? Height : Height_D) + "px";
            }
            if (Width != null || Width_D != null)
            {
                styles["Width"] = (Width != Util.NaN ? Width : Width_D) + "px";
            }
        }
        #endregion

    }
}
